fix(deps): update module github.com/charmbracelet/lipgloss to v2 - #2769
fix(deps): update module github.com/charmbracelet/lipgloss to v2#2769renovate[bot] wants to merge 1 commit into
Conversation
|
4d3f58b to
53ef58c
Compare
53ef58c to
4047dfb
Compare
4047dfb to
e110b89
Compare
pikachuren
left a comment
There was a problem hiding this comment.
🙏 感谢贡献
感谢 @app/renovate 提交此自动依赖更新 PR!我已完成代码评审,以下是评审结果。
🤖 AI 自动审核声明
本评审报告由 AI 自动生成,当前使用 Claude Opus 5 模型进行分析,部分复杂场景可能辅助使用 ChatGPT、DeepSeek 等模型进行交叉验证。
⚠️ AI 分析结果仅供参考,可能存在误判或遗漏。如您发现任何问题或有不同意见,欢迎随时提出讨论和纠正。
⚠️ 重要提醒:即使 AI 评审认为代码质量良好且建议合并,最终是否合并仍需由项目维护者进行人工判定。项目维护者会综合考虑代码质量、项目规划、技术方向、团队资源等多方面因素做出决策。
📖 PR背景与需求
PR标题:fix(deps): update module github.com/charmbracelet/lipgloss to v2
依赖更新类型:主版本升级(Major Version Update)
需求说明:
Renovate Bot 自动创建的依赖更新 PR,将 github.com/charmbracelet/lipgloss 从 v1.1.0 升级到 v2.0.5(主版本升级)。
预期目标:
- 使用 lipgloss v2 的新功能和改进
- 修复 v1 中存在的 bug
- 跟进上游库的最新稳定版本
📋 问题摘要
⚠️ 破坏性变更风险:主版本升级包含不兼容的 API 变更(⚠️ 高风险)⚠️ 不完整迁移:同时保留 v1 和 v2 两个版本,依赖冗余(⚠️ 重要)⚠️ 缺少兼容性验证:未检查代码是否需要适配新 API(⚠️ 关键)- 💡 需要测试验证:必须运行完整测试套件确认无回归
📂 逐文件分析
go.mod
改动意图:
将 lipgloss 依赖从 v1.1.0 升级到 v2.0.5。
代码修改逻辑:
- github.com/charmbracelet/lipgloss v1.1.0
+ github.com/charmbracelet/lipgloss/v2 v2.0.5在 Go modules 中,主版本 v2+ 需要在模块路径中包含版本后缀(/v2),因此这是一个模块路径变更,而不是简单的版本号升级。
合理性评估:
✅ 优点:
- 符合 Go modules 规范:正确使用了
/v2路径后缀 - 版本选择合理:v2.0.5 是 v2 系列的稳定版本,包含多个 bug 修复
- 上游质量良好:lipgloss v2 经过充分测试,由 Charm 团队维护
-
依赖冗余问题(
⚠️ 关键)- 当前
go.mod中可能同时保留了 v1 和 v2 两个版本 - 这会导致编译后的二进制文件包含两份 lipgloss 代码,显著增大体积
- 需要检查
go.mod的完整内容和go.sum,确认是否真的存在冗余
- 当前
-
代码兼容性问题(
⚠️ 高风险)-
lipgloss v2 包含破坏性 API 变更,根据官方 changelog:
- 颜色系统重构:
lipgloss.Color现在返回color.Color接口 - 自适应颜色变更:
AdaptiveColor类型被移除,需使用compat包或新 API - 背景色检测变更:需手动调用
HasDarkBackground()或使用compat包 - 颜色降采样变更:非 Bubble Tea 场景需使用
lipgloss.Println()等 writer 函数
- 颜色系统重构:
-
必须检查的代码位置:
- 所有
import "github.com/charmbracelet/lipgloss"需改为lipgloss/v2 - 所有使用
lipgloss.AdaptiveColor的地方需要迁移 - 所有使用
fmt.Println(style.Render(...))的地方需改为lipgloss.Println(...)
- 所有
-
-
迁移策略不明确
- 是完全迁移到 v2?(推荐)
- 还是渐进式迁移?(需要明确计划)
- 还是意外引入?(需要回退)
❌ 明确问题:
-
缺少兼容性验证
- PR 描述中没有提到是否检查了代码兼容性
- 没有提到是否运行了测试套件
- 没有提到是否查阅了 v2 的 breaking changes
-
缺少迁移说明
- 没有说明哪些代码需要修改
- 没有提供迁移 checklist
- 没有说明是否使用了
compat包作为过渡方案
🎯 总体评价
功能性:
安全性:⭐⭐⭐⭐ - lipgloss 不涉及安全关键逻辑,上游可信
代码质量:
实现方案:
建议操作:
- ✅ Approve(建议合并)
- 🔄 Request Changes(需要修改)
- ❌ Close(建议关闭)
理由:
此 PR 是一个主版本升级,包含破坏性 API 变更,需要谨慎处理。当前状态存在以下关键问题:
-
不确定是否完成了代码迁移:
- 仅修改了
go.mod,但没有看到任何代码层面的修改 - lipgloss v2 的 API 变更需要修改所有使用 lipgloss 的代码
- 如果没有修改代码,这个 PR 肯定会导致编译失败
- 仅修改了
-
可能存在依赖冗余:
- 需要确认 v1 是否已被完全移除
- 运行
go mod tidy并检查go.mod中是否还有 v1
-
缺少测试验证:
- 主版本升级必须运行完整的测试套件
- 需要确认所有功能正常,无回归
📝 详细建议
必须完成的步骤(按顺序):
1. 调查当前代码的 lipgloss 使用情况
# 搜索所有导入 lipgloss 的文件
grep -r "github.com/charmbracelet/lipgloss" . --include="*.go"
# 搜索所有使用 AdaptiveColor 的地方
grep -r "AdaptiveColor" . --include="*.go"
# 搜索所有使用 fmt.Println 打印样式的地方(需改为 lipgloss.Println)
grep -r "fmt.Println.*Render" . --include="*.go"2. 决定迁移策略
方案 A:完全迁移到 v2(✅ 推荐)
优点:
- 清理了依赖,减小二进制体积
- 使用最新功能和 bug 修复
- 长期维护更简单
步骤:
- 修改所有 import 语句:
import "github.com/charmbracelet/lipgloss/v2" - 根据 v2 升级指南 修改代码:
- 使用
compat包替换AdaptiveColor - 使用
lipgloss.Println()替换fmt.Println()(如果不使用 Bubble Tea)
- 使用
- 运行
go mod tidy - 运行完整测试:
go test ./... - 手动测试 TUI 功能,确认样式渲染正常
方案 B:保持 v1
如果迁移成本过高或 v2 有不可接受的问题:
- 关闭此 PR
- 在
renovate.json中配置忽略 lipgloss v2:{ "packageRules": [ { "matchPackageNames": ["github.com/charmbracelet/lipgloss"], "allowedVersions": "< 2.0.0" } ] }
方案 C:渐进式迁移
如果项目较大,希望分步迁移:
- 制定明确的迁移计划和时间表
- 先引入 v2,使用
compat包确保兼容性 - 逐步重构代码,最终完全迁移到 v2 原生 API
- 但要注意:同时维护两个版本会增加二进制体积,应尽快完成迁移
3. 查阅官方迁移指南
必读文档:
关键变更摘要:
| v1 API | v2 API | 说明 |
|---|---|---|
lipgloss.AdaptiveColor{Light: "...", Dark: "..."} |
compat.AdaptiveColor{Light: lipgloss.Color("..."), Dark: lipgloss.Color("...")} 或 lipgloss.LightDark(isDark) |
自适应颜色需使用 compat 包或新 API |
fmt.Println(style.Render("text")) |
lipgloss.Println(style.Render("text")) |
非 Bubble Tea 场景需使用 lipgloss writer |
lipgloss.Color("#ff0000") |
lipgloss.Color("#ff0000") |
现在返回 color.Color 接口 |
| 自动背景色检测 | lipgloss.HasDarkBackground(os.Stdin, os.Stdout) |
需手动检测或使用 compat 包 |
4. 运行测试并验证
# 确保依赖正确
go mod tidy
# 运行单元测试
go test ./... -v
# 运行集成测试(如果有)
go test ./... -tags=integration
# 编译检查
go build ./...
# 手动测试 TUI 功能
# 启动应用,检查:
# - 样式渲染是否正常
# - 颜色是否正确(浅色/深色主题)
# - 是否有崩溃或错误💡 快速修复建议(如果选择完全迁移)
示例:使用 compat 包作为过渡方案
如果你的代码中使用了 AdaptiveColor,最简单的迁移方式是使用 compat 包:
// Before (v1)
import "github.com/charmbracelet/lipgloss"
var myColor = lipgloss.AdaptiveColor{Light: "#f1f1f1", Dark: "#333333"}
// After (v2, 使用 compat 包)
import (
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/lipgloss/v2/compat"
)
var myColor = compat.AdaptiveColor{
Light: lipgloss.Color("#f1f1f1"),
Dark: lipgloss.Color("#333333"),
}示例:修改输出方式
如果你不使用 Bubble Tea,需要改用 lipgloss writer:
// Before (v1)
import (
"fmt"
"github.com/charmbracelet/lipgloss"
)
s := someStyle.Render("Hello!")
fmt.Println(s)
// After (v2)
import "github.com/charmbracelet/lipgloss/v2"
s := someStyle.Render("Hello!")
lipgloss.Println(s) // 自动处理颜色降采样🔍 需要回答的问题
在合并此 PR 之前,请确认以下问题:
- ✅ 是否查阅了 lipgloss v2 的升级指南和 breaking changes?
- ✅ 是否修改了所有使用 lipgloss 的代码以适配 v2 API?
- ✅ 是否运行了
go mod tidy并确认 v1 已被移除? - ✅ 是否运行了完整的测试套件并通过?
- ✅ 是否手动测试了 TUI 功能,确认样式渲染正常?
- ✅ 是否检查了编译后的二进制文件大小,确认无依赖冗余?
如果以上任何一项为 ❌,此 PR 不应合并。
📚 参考资料
总结
这是一个需要谨慎处理的主版本升级 PR。建议:
- 暂不合并,先完成代码迁移工作
- 制定迁移计划,决定使用哪种方案(完全迁移/保持 v1/渐进迁移)
- 彻底测试,确保无回归
- 更新 PR 描述,说明迁移工作的进展和测试结果
如果需要帮助迁移代码,请随时提问!我可以协助分析具体的代码修改需求。
This PR contains the following updates:
v1.1.0→v2.0.5Release Notes
charmbracelet/lipgloss (github.com/charmbracelet/lipgloss)
v2.0.5Compare Source
Changelog
Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
v2.0.4Compare Source
Mini Crash Patch
Hi! This is a small patch to fix a writer-related panic. Thanks for using Lip Gloss!
Changelog
Fixed
fefa41d: fix: prevent crash when writing to a closed wrap writer (#699) (@taciturnaxolotl)Docs
40ec0e6: docs: fix typo in table comment (#641) (@aymanbagabas)a4d0b40: docs: restore missing diaereses (#664) (@meowgorithm)Chore
aa91b99: chore: remove CODEOWNERS (@aymanbagabas)9cbfe8b: chore(lint): exclude revive naming linter (@aymanbagabas)Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
v2.0.3Compare Source
Changelog
Fixed
472d718: fix: Avoid background color query hang (#636) (@jedevc)Docs
9e39a0a: docs: fix README typo (#629) (@Rohan5commit)cd93a9f: docs: fix tree comment typo (#634) (@Rohan5commit)Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
v2.0.2Compare Source
Table patch
If you don't know, we made big improvements in table rendering recently shipped in v2.0.0.
@MartinodF made a good job on improving it even further for tricky edge cases, in particular when content wrapping is enabled.
Changelog
Fixed
c289bad: fix(table): height and overflow with wrapping content (#620) (@MartinodF)Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
v2.0.1Compare Source
A small release to properly set style underline colors, as well as handling partial reads while querying the terminal.
Changelog
Fixed
3044146: fix: add missing underlineColorKey case in getAsColor (#624) (@flux627)Docs
61e734b: docs: Charm logo link in upgrade guide (@aymanbagabas)Other stuff
92b13d8: ci: sync golangci-lint config (#621) (@github-actions[bot])Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.
v2.0.0Compare Source
Do you think you can handle Lip Gloss v2?
We’re really excited for you to try Lip Gloss v2! Read on for new features and a guide to upgrading.
If you (or your LLM) just want the technical details, take a look at Upgrade Guide.
What’s new?
The big changes are that Styles are now deterministic (λipgloss!) and you can be much more intentional with your inputs and outputs. Why does this matter?
Playing nicely with others
v2 gives you precise control over I/O. One of the issues we saw with the Lip Gloss and Bubble Tea v1s is that they could fight over the same inputs and outputs, producing lock-ups. The v2s now operate in lockstep.
Querying the right inputs and outputs
In v1, Lip Gloss defaulted to looking at
stdinandstdoutwhen downsampling colors and querying for the background color. This was not always necessarily what you wanted. For example, if your application was writing tostderrwhile redirectingstdoutto a file, the program would erroneously think output was not a TTY and strip colors. Lip Gloss v2 gives you control over this.Going beyond localhost
Did you know TUIs and CLIs can be served over the network? For example, Wish allows you to serve Bubble Tea and Lip Gloss over SSH. In these cases, you need to work with the input and output of the connected clients as opposed to
stdinandstdout, which belong to the server. Lip Gloss v2 gives you flexibility around this in a more natural way.🧋 Using Lip Gloss with Bubble Tea?
Make sure you get all the latest v2s as they’ve been designed to work together.
# Collect the whole set. go get charm.land/bubbletea/v2 go get charm.land/bubbles/v2 go get charm.land/lipgloss/v2🐇 Quick upgrade
If you don't have time for changes and just want to upgrade to Lip Gloss v2 as fast as possible? Here’s a quick guide:
Use the
compatpackageThe
compatpackage provides adaptive colors, complete colors, and complete adaptive colors:compatworks by looking atstdinandstdouton a global basis. Want to change the inputs and outputs? Knock yourself out:Use the new Lip Gloss writer
If you’re using Bubble Tea with Lip Gloss you can skip this step. If you're using Lip Gloss in a standalone fashion, however, you'll want to use
lipgloss.Println(andlipgloss.Printfand so on) when printing your output:Why? Because
lipgloss.Printlnwill automatically downsample colors based on the environment.That’s it!
Yep, you’re done. All this said, we encourage you to read on to get the full benefit of v2.
👀 What’s changing?
Only a couple main things that are changing in Lip Gloss v2:
🪄 Downsampling colors with a writer
One of the best things about Lip Gloss is that it can automatically downsample colors to the best available profile, stripping colors (and ANSI) entirely when output is not a TTY.
If you're using Lip Gloss with Bubble Tea there's nothing to do here: downsampling is built into Bubble Tea v2. If you're not using Bubble Tea you now need to use a writer to downsample colors. Lip Gloss writers are a drop-in replacement for the usual functions found in the
fmtpackage:🌛 Background color detection and adaptive colors
Rendering different colors depending on whether the terminal has a light or dark background is an awesome power. Lip Gloss v2 gives you more control over this progress. This especially matters when input and output are not
stdinandstdout.If that doesn’t matter to you and you're only working with
stdoutyou skip this viacompatabove, though we encourage you to explore this new functionality.With Bubble Tea
In Bubble Tea, request the background color, listen for a
BackgroundColorMsgin your update, and respond accordingly.Standalone
If you're not using Bubble Tea you simply can perform the query manually:
🥕 Other stuff
Colors are now
color.Colorlipgloss.Color()now produces an idiomaticcolor.Color, whereas before colors were typelipgloss.TerminalColor. Generally speaking, this is more of an implementation detail, but it’s worth noting the structural differences.Changelog
New!
Fixed
Docs
Other stuff
🌈 Feedback
That's a wrap! Feel free to reach out, ask questions, and let us know how it's going. We'd love to know what you think.
Part of Charm.
Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.